typeof 1; // 'number'
typeof "1"; // 'string'
typeof undefined; // 'undefined'
typeof true; // 'boolean'
typeof Symbol(); // 'symbol'
typeof null; // 'object'
typeof []; // 'object'
typeof {}; // 'object'
typeof console; // 'object'
typeof console.log; // 'function'
console.log(typeof 1);
console.log(typeof "1");
console.log(typeof undefined);
console.log(typeof true);
console.log(typeof Symbol());
console.log(typeof null);
console.log(typeof null);
console.log(typeof []);
console.log(typeof {});
console.log(typeof console);
console.log(typeof console.log);

let Car = function () {};
let benz = new Car();
console.dir(Car.__proto__);
// 每个对象都有原型,将指向该对象该实例的构造函数的prototype属性所指向的对象
// 实例的__proto__一层一层就是原型莲
Object.getPrototypeOf(benz);

function getType(obj) {
  let type = typeof obj;
  if (type !== "object") {
    // typeof
    return type;
  }
  // typeof object
  return Object.prototype.toString
    .call(obj)
    .replace(/^\[object (\S+)\]$/, "$1");
}
console.log(getType("a"));
console.log(getType({}));
console.log(getType([]));
console.log(getType(() => {}));
{
  //
  let greeting = "Hello World!";
  var lang = "English";
  console.log(greeting); // Prints 'Hello World!'
}
// 'English'
console.log(lang);
// Uncaught ReferenceError: greeting is not defined
console.log(greeting);
